<?php

namespace App\Models;

class PlayerRecord extends Model
{

    //
    protected $table = 'record_player';

    public function player()
    {
        return $this->belongsTo(Player::class, 'player_id', 'id');
    }

    public function countsnum()
    {
        return $this->belongsTo(RecordCounts::class, 'player_id', 'player_id');
    }

    public function getCreatedAtAttribute($value)
    {
        return date('Y-m-d H:i:s', strtotime($value));
    }

    public function getUpdatedAtAttribute($value)
    {
        return date('Y-m-d H:i:s', strtotime($value));
    }

    public function getRoleTypeAttribute($value)
    {
        return [1 => '坏人', 2 => '好人'][$value];
    }
}
